//#include "gndmainwin.h"

#include "gnd.h"

G_DEFINE_TYPE(GndMainwin, gnd_mainwin, GTK_TYPE_WINDOW)


void gnd_set_img_background(GndMainwin * self);
void gnd_set_device_info_page(GndMainwin * self);
void gnd_set_file_page(GndMainwin * self);
void gnd_set_app_page(GndMainwin * self);
void gnd_set_tool_page(GndMainwin * self);


void gnd_set_device_info_page(GndMainwin * self)
{
    self->device_info_page = g_new(GndDeviceInfoPage, 1);
    GndDeviceInfoPage * device_info_page = self->device_info_page;
    device_info_page->hbox_main = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    device_info_page->vbox_device_screen = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    device_info_page->grid_device_info = (GtkGrid *) gtk_grid_new();
    device_info_page->image_device_screen = (GtkImage *) gtk_image_new();
    //device screenshot control
    device_info_page->button_box_device_screen_control = (GtkButtonBox *) gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    device_info_page->button_screen_refresh = (GtkButton *) gtk_button_new_with_label("开始");
    device_info_page->button_screen_save = (GtkButton *) gtk_button_new_with_label("保存");
    device_info_page->button_screen_setting = (GtkButton *) gtk_button_new_with_label("设置");

    device_info_page->separator_info_page = (GtkSeparator *) gtk_separator_new(GTK_ORIENTATION_VERTICAL);
    device_info_page->vbox_device_info = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    //device info label
    device_info_page->label_model = (GtkLabel *) gtk_label_new("设备型号");
    device_info_page->label_model_info = (GtkLabel *) gtk_label_new("ZUK Z2");
    device_info_page->label_manuf = (GtkLabel *) gtk_label_new("厂商");
    device_info_page->label_manuf_info = (GtkLabel *) gtk_label_new("联想");
    device_info_page->label_sysver = (GtkLabel *) gtk_label_new("系统版本");
    device_info_page->label_sysver_info = (GtkLabel *) gtk_label_new("Android 7.0");
    device_info_page->label_kernel = (GtkLabel *) gtk_label_new("内核版本");
    device_info_page->label_kernel_info = (GtkLabel *) gtk_label_new("Linux 3.10");
    device_info_page->label_imei = (GtkLabel *) gtk_label_new("imei");
    device_info_page->label_imei_info = (GtkLabel *) gtk_label_new("865872025238821");
    device_info_page->label_mac = (GtkLabel *) gtk_label_new("mac");
    device_info_page->label_mac_info = (GtkLabel *) gtk_label_new("a8:a6:68:a3:d9:ef");
    device_info_page->label_cpu = (GtkLabel *) gtk_label_new("处理器");
    device_info_page->label_cpu_info = (GtkLabel *) gtk_label_new("MT6592");
    device_info_page->label_sdk_api = (GtkLabel *) gtk_label_new("sdk api");
    device_info_page->label_sdk_api_info = (GtkLabel *) gtk_label_new("19");
    device_info_page->label_brand = (GtkLabel *) gtk_label_new("品牌");
    device_info_page->label_brand_info = (GtkLabel *) gtk_label_new("Huawei");
    device_info_page->label_product = (GtkLabel *) gtk_label_new("产品名称");
    device_info_page->label_product_info = (GtkLabel *) gtk_label_new("G750-T01");
    device_info_page->label_cpu_abi = (GtkLabel *) gtk_label_new("cpu架构");
    device_info_page->label_cpu_abi_info = (GtkLabel *) gtk_label_new("armv8");
    device_info_page->label_resolution = (GtkLabel *) gtk_label_new("分辨率");
    device_info_page->label_resolution_info = (GtkLabel *) gtk_label_new("1080x1920");
    device_info_page->label_ram = (GtkLabel *) gtk_label_new("内存");
    device_info_page->label_ram_info = (GtkLabel *) gtk_label_new("4GB");
    device_info_page->label_rom = (GtkLabel *) gtk_label_new("磁盘");
    device_info_page->label_rom_info = (GtkLabel *) gtk_label_new("64GB");

    device_info_page->grid_disk_info = (GtkGrid *) gtk_grid_new();
    device_info_page->label_disk_info = (GtkLabel *) gtk_label_new("设备磁盘使用量");
    device_info_page->levelbar_disk_usage = (GtkLevelBar *) gtk_level_bar_new();
    device_info_page->label_disk_usage = (GtkLabel *) gtk_label_new("12.3GB used/64GB total");
    device_info_page->button_disk_manage = (GtkButton *) gtk_button_new_from_icon_name("drive-harddisk", GTK_ICON_SIZE_BUTTON);




    /*将截屏的控制按钮放入按钮盒中*/
    gtk_box_pack_start(GTK_BOX(device_info_page->button_box_device_screen_control),
                       GTK_WIDGET(device_info_page->button_screen_refresh), TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(device_info_page->button_box_device_screen_control),
                       GTK_WIDGET(device_info_page->button_screen_save), TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(device_info_page->button_box_device_screen_control),
                       GTK_WIDGET(device_info_page->button_screen_setting), TRUE, TRUE, 0);

    //hbox_main Packing
    gtk_box_pack_start(GTK_BOX(device_info_page->hbox_main), GTK_WIDGET(device_info_page->vbox_device_screen),
                       TRUE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(device_info_page->hbox_main), GTK_WIDGET(device_info_page->separator_info_page),
                       FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(device_info_page->hbox_main), GTK_WIDGET(device_info_page->vbox_device_info),
                       FALSE, FALSE, 0);

    //vbox_device_info Packing
    gtk_box_pack_start(device_info_page->vbox_device_info, GTK_WIDGET(device_info_page->grid_device_info),
                       FALSE, FALSE, 0);
    gtk_box_pack_end(device_info_page->vbox_device_info, GTK_WIDGET(device_info_page->grid_disk_info),
                     FALSE, FALSE, 0);
    //vbox_device_screen Packing
    gtk_box_pack_start(device_info_page->vbox_device_screen, GTK_WIDGET(device_info_page->image_device_screen),
                       FALSE, FALSE, 0);
    gtk_box_pack_start(device_info_page->vbox_device_screen, GTK_WIDGET(device_info_page->button_box_device_screen_control),
                       FALSE, FALSE, 0);
    //device screen setting

    gtk_button_box_set_layout(device_info_page->button_box_device_screen_control, GTK_BUTTONBOX_EXPAND);
    gtk_widget_set_margin_top(GTK_WIDGET(device_info_page->button_box_device_screen_control), 5);
    gtk_widget_set_margin_start(GTK_WIDGET(device_info_page->vbox_device_screen), 10);
    gtk_widget_set_margin_end(GTK_WIDGET(device_info_page->vbox_device_screen), 10);
    gtk_widget_set_margin_top(GTK_WIDGET(device_info_page->vbox_device_screen), 10);
    gtk_widget_set_valign(GTK_WIDGET(device_info_page->vbox_device_screen), GTK_ALIGN_CENTER);
    gtk_widget_set_halign(GTK_WIDGET(device_info_page->vbox_device_screen), GTK_ALIGN_CENTER);
    gtk_widget_set_size_request(GTK_WIDGET(device_info_page->image_device_screen), GND_MAINWIN_SCREENCAP_W,
                                GND_MAINWIN_SCREENCAP_H);
    //device info setting
    gtk_widget_set_size_request(GTK_WIDGET(device_info_page->grid_device_info), 300, -1);
    gtk_grid_set_column_homogeneous(device_info_page->grid_device_info, TRUE);
    gtk_grid_set_row_spacing(device_info_page->grid_device_info, 10);
    gtk_grid_set_column_spacing(device_info_page->grid_device_info, 20);

    gtk_grid_set_column_homogeneous(device_info_page->grid_disk_info, TRUE);
    gtk_grid_set_row_spacing(device_info_page->grid_disk_info, 5);
    gtk_widget_set_halign(GTK_WIDGET(device_info_page->button_disk_manage), GTK_ALIGN_END);
    gtk_widget_set_halign(GTK_WIDGET(device_info_page->label_disk_info), GTK_ALIGN_START);
    gtk_widget_set_halign(GTK_WIDGET(device_info_page->label_disk_usage), GTK_ALIGN_START);

    gtk_widget_set_margin_top(GTK_WIDGET(device_info_page->vbox_device_info), 10);
    gtk_widget_set_margin_bottom(GTK_WIDGET(device_info_page->vbox_device_info), 10);
    gtk_widget_set_margin_end(GTK_WIDGET(device_info_page->vbox_device_info), 10);
    gtk_widget_set_margin_start(GTK_WIDGET(device_info_page->vbox_device_info), 10);


    //disk usage info attaching :grid_disk_info
    gtk_grid_attach(device_info_page->grid_disk_info,
                    GTK_WIDGET(device_info_page->label_disk_info),
                    0, 0, 1, 1);
    gtk_grid_attach(device_info_page->grid_disk_info,
                    GTK_WIDGET(device_info_page->levelbar_disk_usage),
                    0, 1, 2, 1);
    gtk_grid_attach(device_info_page->grid_disk_info,
                    GTK_WIDGET(device_info_page->label_disk_usage),
                    0, 2, 1, 1);
    gtk_grid_attach(device_info_page->grid_disk_info,
                    GTK_WIDGET(device_info_page->button_disk_manage),
                    1, 2, 1, 1);




//--Label Attach Begin :model
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_model),
                    0, 0, 1, 1);
    gtk_label_set_xalign(device_info_page->label_model, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_model_info),
                    1, 0, 1, 1);
    gtk_label_set_xalign(device_info_page->label_model_info, 0);
//-- :manuf
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_manuf),
                    0, 1, 1, 1);
    gtk_label_set_xalign(device_info_page->label_manuf, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_manuf_info),
                    1, 1, 1, 1);
    gtk_label_set_xalign(device_info_page->label_manuf_info, 0);

//brand
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_brand),
                    0, 2, 1, 1);
    gtk_label_set_xalign(device_info_page->label_brand, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_brand_info),
                    1, 2, 1, 1);
    gtk_label_set_xalign(device_info_page->label_brand_info, 0);

//product
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_product),
                    0, 3, 1, 1);
    gtk_label_set_xalign(device_info_page->label_product, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_product_info),
                    1, 3, 1, 1);
    gtk_label_set_xalign(device_info_page->label_product_info, 0);

//-- :sysver
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_sysver),
                    0, 4, 1, 1);
    gtk_label_set_xalign(device_info_page->label_sysver, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_sysver_info),
                    1, 4, 1, 1);
    gtk_label_set_xalign(device_info_page->label_sysver_info, 0);

//sdk_api
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_sdk_api),
                    0, 5, 1, 1);
    gtk_label_set_xalign(device_info_page->label_sdk_api, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_sdk_api_info),
                    1, 5, 1, 1);
    gtk_label_set_xalign(device_info_page->label_sdk_api_info, 0);

//-- :kernel
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_kernel),
                    0, 6, 1, 1);
    gtk_label_set_xalign(device_info_page->label_kernel, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_kernel_info),
                    1, 6, 1, 1);
    gtk_label_set_xalign(device_info_page->label_kernel_info, 0);

//-- :imei
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_imei),
                    0, 7, 1, 1);
    gtk_label_set_xalign(device_info_page->label_imei, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_imei_info),
                    1, 7, 1, 1);
    gtk_label_set_xalign(device_info_page->label_imei_info, 0);

//mac
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_mac),
                    0, 8, 1, 1);
    gtk_label_set_xalign(device_info_page->label_mac, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_mac_info),
                    1, 8, 1, 1);
    gtk_label_set_xalign(device_info_page->label_mac_info, 0);

//cpu
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_cpu),
                    0, 9, 1, 1);
    gtk_label_set_xalign(device_info_page->label_cpu, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_cpu_info),
                    1, 9, 1, 1);
    gtk_label_set_xalign(device_info_page->label_cpu_info, 0);



//cpu_abi
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_cpu_abi),
                    0, 10, 1, 1);
    gtk_label_set_xalign(device_info_page->label_cpu_abi, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_cpu_abi_info),
                    1, 10, 1, 1);
    gtk_label_set_xalign(device_info_page->label_cpu_abi_info, 0);

//resolution
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_resolution),
                    0, 11, 1, 1);
    gtk_label_set_xalign(device_info_page->label_resolution, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_resolution_info),
                    1, 11, 1, 1);
    gtk_label_set_xalign(device_info_page->label_resolution_info, 0);

//ram
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_ram),
                    0, 12, 1, 1);
    gtk_label_set_xalign(device_info_page->label_ram, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_ram_info),
                    1, 12, 1, 1);
    gtk_label_set_xalign(device_info_page->label_ram_info, 0);

//rom
    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_rom),
                    0, 13, 1, 1);
    gtk_label_set_xalign(device_info_page->label_rom, 1);

    gtk_grid_attach(device_info_page->grid_device_info,
                    GTK_WIDGET(device_info_page->label_rom_info),
                    1, 13, 1, 1);
    gtk_label_set_xalign(device_info_page->label_rom_info, 0);

//--Label Attach End


    gtk_stack_add_titled(self->stack, GTK_WIDGET(device_info_page->hbox_main), "device_info", "详情");

    gnd_set_img_background(self);
}


void gnd_set_file_page(GndMainwin *self)
{
    self->file_page = g_new(GndFilePage, 1);
    GndFilePage * file_page = self->file_page;
    file_page->vbox_main = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    file_page->hbox_path_control = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    file_page->hbox_disk_usage = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    file_page->btn_pre_page = (GtkButton *) gtk_button_new_from_icon_name("go-previous", GTK_ICON_SIZE_BUTTON);
    file_page->btn_next_page = (GtkButton *) gtk_button_new_from_icon_name("go-next", GTK_ICON_SIZE_BUTTON);
    file_page->btn_up_page = (GtkButton *) gtk_button_new_from_icon_name("go-up", GTK_ICON_SIZE_BUTTON);
    file_page->btn_path_enter = (GtkButton *) gtk_button_new_from_icon_name("view-refresh", GTK_ICON_SIZE_BUTTON);
    file_page->btn_import = (GtkButton *) gtk_button_new_from_icon_name("list-add", GTK_ICON_SIZE_BUTTON);
    file_page->entry_path = (GtkEntry *) gtk_entry_new();
    file_page->treeview_file_list = (GtkTreeView *) gtk_tree_view_new();
    file_page->levelbar_disk_usage = (GtkLevelBar *) gtk_level_bar_new();
    file_page->label_disk_usage = (GtkLabel *) gtk_label_new("13.3GB used/64GB total");


    gtk_box_pack_start(file_page->vbox_main, GTK_WIDGET(file_page->hbox_path_control), FALSE, FALSE, 0);
    gtk_box_pack_start(file_page->vbox_main, GTK_WIDGET(file_page->treeview_file_list), TRUE, TRUE, 0);
    gtk_box_pack_start(file_page->vbox_main, GTK_WIDGET(file_page->hbox_disk_usage), FALSE, FALSE, 0);

    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->btn_pre_page), FALSE, FALSE, 0);
    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->btn_next_page), FALSE, FALSE, 0);
    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->btn_up_page), FALSE, FALSE, 0);
    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->entry_path), TRUE, TRUE, 0);
    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->btn_path_enter),  FALSE, FALSE, 0);
    gtk_box_pack_start(file_page->hbox_path_control, GTK_WIDGET(file_page->btn_import),  FALSE, FALSE, 0);


    gtk_box_pack_start(file_page->hbox_disk_usage, GTK_WIDGET(file_page->levelbar_disk_usage), TRUE, TRUE, 0);
    gtk_box_pack_start(file_page->hbox_disk_usage, GTK_WIDGET(file_page->label_disk_usage), FALSE, TRUE, 0);

    //gtk_widget_set_halign(GTK_WIDGET(file_page->label_disk_usage), GTK_ALIGN_END);
    gtk_box_set_spacing(file_page->vbox_main, 5);
    gtk_box_set_spacing(file_page->hbox_path_control, 5);
    gtk_box_set_spacing(file_page->hbox_disk_usage, 5);
    g_object_set(file_page->vbox_main, "margin", 5, NULL);

    gtk_stack_add_titled(self->stack, GTK_WIDGET(file_page->vbox_main), "file_page", "文件管理");
}


void gnd_set_app_page(GndMainwin *self)
{
    self->app_page = g_new(GndAppPage, 1);
    GndAppPage * app_page = self->app_page;

    app_page->vbox_main = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    app_page->hbox_control = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    app_page->treeview_app_list = (GtkTreeView *) gtk_tree_view_new();
    app_page->check_button_sysapp_show = (GtkCheckButton *) gtk_check_button_new_with_label("显示系统应用");
    app_page->btn_app_install = (GtkButton *) gtk_button_new_with_label("安装应用");
    app_page->btn_refresh = (GtkButton *) gtk_button_new_from_icon_name("view-refresh", GTK_ICON_SIZE_BUTTON);

    gtk_box_pack_start(app_page->vbox_main, GTK_WIDGET(app_page->treeview_app_list), TRUE, TRUE, 0);
    gtk_box_pack_start(app_page->vbox_main, GTK_WIDGET(app_page->hbox_control), FALSE, FALSE, 0);

    gtk_box_pack_start(app_page->hbox_control, GTK_WIDGET(app_page->check_button_sysapp_show), FALSE, FALSE, 0);
    gtk_box_pack_end(app_page->hbox_control, GTK_WIDGET(app_page->btn_app_install), FALSE, FALSE, 0);
    gtk_box_pack_end(app_page->hbox_control, GTK_WIDGET(app_page->btn_refresh), FALSE, FALSE, 0);

    gtk_box_set_spacing(app_page->vbox_main, 5);
    gtk_box_set_spacing(app_page->hbox_control, 5);
    g_object_set(app_page->vbox_main, "margin", 5, NULL);


    gtk_stack_add_titled(self->stack, GTK_WIDGET(app_page->vbox_main), "app_page", "应用管理");
}


void gnd_set_tool_page(GndMainwin *self)
{
    self->tool_page = g_new(GndToolPage, 1);
    GndToolPage * tool_page = self->tool_page;

    tool_page->vbox_main = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    tool_page->scrolledwin_tool = (GtkScrolledWindow *) gtk_scrolled_window_new(NULL, NULL);
    tool_page->flowbox_tool = (GtkFlowBox *) gtk_flow_box_new();

    gtk_box_pack_start(tool_page->vbox_main, GTK_WIDGET(tool_page->scrolledwin_tool), TRUE, TRUE, 0);

    gtk_container_add(GTK_CONTAINER(tool_page->scrolledwin_tool), GTK_WIDGET(tool_page->flowbox_tool));

    gtk_widget_set_size_request(GTK_WIDGET(tool_page->flowbox_tool), -1, 600);

    gtk_stack_add_titled(self->stack, GTK_WIDGET(tool_page->vbox_main), "tool_page", "工具");
}


void gnd_mainwin_init(GndMainwin *self)
{
    //GtkWindow * win = GTK_WINDOW(self);
    GtkWindow * win = &self->parent;
    self->header_bar = (GtkHeaderBar *) gtk_header_bar_new();
    self->stack_switcher = (GtkStackSwitcher *) gtk_stack_switcher_new();
    self->stack = (GtkStack *) gtk_stack_new();
    self->vbox_mainpage = (GtkBox *) gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    self->status_bar = (GtkStatusbar *) gtk_statusbar_new();
    self->menubtn_menu = (GtkMenuButton *) gtk_menu_button_new();
    self->popover_menu = (GtkPopover *) gtk_popover_new(GTK_WIDGET(self->menubtn_menu));
    self->combobox_devices = (GtkComboBoxText *) gtk_combo_box_text_new();
    self->button_refresh = (GtkButton *) gtk_button_new_from_icon_name("view-refresh", GTK_ICON_SIZE_BUTTON);
    //self->button_connect = gtk_button_new_from_icon_name("gtk-disconnect", GTK_ICON_SIZE_BUTTON);
    //self->button_refresh = gtk_button_new_with_label("刷新");
    self->button_connect = (GtkButton *) gtk_button_new_with_label("连接");


    //gtk_header_bar_set_title(self->header_bar, "标题");
    gtk_header_bar_set_show_close_button(self->header_bar, TRUE);
    gtk_header_bar_set_custom_title(self->header_bar, GTK_WIDGET(self->stack_switcher));
    gtk_header_bar_pack_end(self->header_bar, GTK_WIDGET(self->menubtn_menu));

    gtk_menu_button_set_popover(self->menubtn_menu, GTK_WIDGET(self->popover_menu));
    gtk_container_add(GTK_CONTAINER(self->menubtn_menu), gtk_image_new_from_icon_name("open-menu-symbolic", GTK_ICON_SIZE_BUTTON));
//=+=+=+
    GtkLabel * label_tmp = (GtkLabel *) gtk_label_new("菜单1\n菜单2\n菜单3");
    gtk_container_add(GTK_CONTAINER(self->popover_menu), GTK_WIDGET(label_tmp));
    gtk_widget_show(GTK_WIDGET(label_tmp));
    //GtkBox * vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
    //gtk_container_add(GTK_CONTAINER(win), vbox);
    //gtk_box_pack_start(vbox, self->header_bar, TRUE, TRUE, 2);
    //GtkButton * btn = gtk_button_new();
    //gtk_box_pack_start(vbox, btn, TRUE, TRUE, 2);
    gtk_window_set_titlebar(win, GTK_WIDGET(self->header_bar));
    gtk_window_set_default_size(GTK_WINDOW(self), 800, 600);
    gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(self->vbox_mainpage));
    gtk_box_pack_start(self->vbox_mainpage, GTK_WIDGET(self->stack), TRUE, TRUE, 0);
    gtk_box_pack_start(self->vbox_mainpage, GTK_WIDGET(self->status_bar), FALSE, FALSE, 0);
    gtk_stack_switcher_set_stack(self->stack_switcher, self->stack);
    gtk_stack_set_transition_type(self->stack, GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);

    gtk_box_pack_end(GTK_BOX(self->status_bar), GTK_WIDGET(self->button_refresh), FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(self->status_bar), GTK_WIDGET(self->button_connect), FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(self->status_bar), GTK_WIDGET(self->combobox_devices), FALSE, FALSE, 0);
    gtk_box_set_spacing(GTK_BOX(self->status_bar), 5);

    gtk_statusbar_push(self->status_bar,
                       gtk_statusbar_get_context_id(self->status_bar, "status"),
                       "已连接设备: ZUK Z2");
    gtk_widget_set_size_request(GTK_WIDGET(self->combobox_devices), 150, -1);
    gnd_set_device_info_page(self);
    gnd_set_file_page(self);
    gnd_set_app_page(self);
    gnd_set_tool_page(self);

}


void gnd_mainwin_class_init(GndMainwinClass *klass)
{

}

GndMainwin * gnd_mainwin_new()
{
    GndMainwin * win = g_object_new(GND_TYPE_MAINWIN,
                                    "type", GTK_WINDOW_TOPLEVEL,
                                    NULL);
    return win;

}


void gnd_set_img_background(GndMainwin *self)
{
    //GError * error = NULL;
    GtkWidget * img_widget = GTK_WIDGET(self->device_info_page->image_device_screen);
    GtkStyleProvider * provider = GTK_STYLE_PROVIDER(gtk_css_provider_new());
//    gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(provider),
//                                    g_file_new_for_path("/home/wsgalaxy/programe/gtk/gnodroid/style.css"), &error);

    gtk_css_provider_load_from_resource(GTK_CSS_PROVIDER(provider), "/com/gitee/wsgalaxy/gnodroid/style.css");
    gtk_style_context_add_provider(gtk_widget_get_style_context(img_widget), provider, G_MAXUINT);
}
